using System;
using NUnit.Framework;
using WatiN.Core;

namespace Roommate.IntegrationTests
{
    [TestFixture]
    public class As_a_user_I_whant_to_make_a_reservation : IntegrationTestFixture
    {

        [Test]
        public void Create_successful_reservation_for_one_room()
        {
            TestConfiguration.SetupSystem(
                x =>
                {
                    x.SetSystemTime(new DateTime(2009,1,1));
                    x.AddRoom("101");
                    x.AddRoom("201");

                }
                );


            Browser.GoTo("http://localhost/booking/create");
            //search for rooms
            Browser.TextField(x => x.Id == "toDate").TypeText("2009-01-01");
            Browser.TextField(x => x.Id == "fromDate").TypeText("2009-01-01");
            Browser.Button(x => x.Id == "btnSearch").Click();

            
            //mark one room
            Browser.CheckBox(Find.By("roomIndex", "0")).WaitUntilExists();
            Browser.CheckBox(Find.By("roomIndex", "0")).Checked = true;
            Assert.IsTrue(Browser.ContainsText("201"), "Room not found");

            //add room tom reservation
            Browser.Button(x => x.Id == "btnAddSelectedRooms").Click();

            //submit reservation
            Browser.Button(x => x.Id == "submitReservation").Click();

            //make sure that the successfull reservation is displayed
            Assert.IsTrue(Browser.ContainsText("This page displays information for booking"));



        }
    }
}